<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>

<script type="text/javascript">
    var errorOpts = {
        msg : "<bean:message key="ticket.read.msg" bundle="errors"/>",
        boxTitle : "<bean:message key="ticket.read.boxTitle" bundle="errors"/>",
        msgStatus: "<bean:message key="ticket.read.msgStatus" bundle="errors"/>"
    };
    
    var loadNoteOpts = {
        msg : "<bean:message key="note.load.msg" bundle="errors"/>",
        boxTitle : "<bean:message key="note.load.boxTitle" bundle="errors"/>",
        msgStatus: "<bean:message key="note.load.msgStatus" bundle="errors"/>"
    };
    
    var errorLoadDialogAttachmentOpts = {
        msg : "<bean:message key="ticket.loadAttachmentDialog.msg" bundle="errors"/>",
        boxTitle : "<bean:message key="ticket.loadAttachmentDialog.boxTitle" bundle="errors"/>",
        msgStatus: "<bean:message key="ticket.loadAttachmentDialog.msgStatus" bundle="errors"/>"
    };

    var errorLoadTicketAttachmentListOpts = {
        msg : "<bean:message key="ticket.loadAttachmentList.msg" bundle="errors"/>",
        boxTitle : "<bean:message key="ticket.loadAttachmentList.boxTitle" bundle="errors"/>",
        msgStatus: "<bean:message key="ticket.loadAttachmentList.msgStatus" bundle="errors"/>"
    };
</script>

<c:forEach items="${requestScope.tickets}" var="entry">
<div class="result">
	<ul class="itemResultNW">
	    <li>
	        <p class="assigned" title="${entry.assignedTo.profile.firstName} ${entry.assignedTo.profile.lastName}">${entry.assignedTo.username}</p>
	    </li>
	    <li>
	        <p class="openDate">${entry.openDate}</p>
	    </li>
	    <li>
	        <p class="closeDate">${entry.closeDate}</p>
	    </li>
	    <li>
            <p class="category" title="${entry.subCategory.description}">${entry.subCategory.name}</p>
        </li>
	    <li>
	        <p class="status" title="${entry.status.description}" >${entry.status.name}</p>
	    </li>
	    <li>
	        <p class="priority" title="${entry.priority.description}">${entry.priority.name}</p>
	    </li>
	    <li>
	        <p class="subject">${entry.subject}</p>
	    </li>
	    <li>
	        <p id="contains-${entry.ticketID}" class="contains">${entry.description}</p>
	        <a class="ReadMoreTicket" href="javascript:showReadingBox('${pageContext.request.contextPath}/ticket/loadTicket.do',${entry.ticketID},'<bean:message key="ticket.boxtitle" bundle="ticket"/>')">[read]</a>
	    </li>
	    <li class="liAttachment" id="attachment-${entry.ticketID}">
	        <c:forEach items="${entry.attachment}" var="attachment">
	            <p class="attachment">
	               <a href="${pageContext.request.contextPath}/file/download.do?attachmentID=${attachment.attachmentID}">
	                   <img class="imgPanelAttachment" src="${pageContext.request.contextPath}/common/loadimg.do?mimeType=${attachment.fileContentType}" alt="Download ${attachment.fileName}" title="Download ${attachment.fileName}" />
	               </a>
	            </p>
	        </c:forEach>
	    </li>
	 	<li class="boxNote" id="boxNote-${entry.ticketID}">
			<p id="noteid-${entry.ticketID}" class="note">
			     <a class="aNote" href="javascript:loadNote('${pageContext.request.contextPath}/ticket/loadticketnote.do', '${entry.ticketID}');">
			         <bean:message key="ticket.opennote" bundle="ticket"/>
			     </a> |
			     <a id="loadAttachment" class="aNote" href="javascript:loadAttachmentFile('${pageContext.request.contextPath}/ticket/activeticketattachment.do', '${entry.ticketID}', '<bean:message key="ticket.attachmentfile" bundle="ticket"/>');">
			       	  <bean:message key="ticket.attachment.add" bundle="ticket"/>
			     </a>
			</p>
			<div id="NoteWrapper-${entry.ticketID}"></div>	
		</li>
	</ul>
</div>
</c:forEach>